package com.platform.system.service.impl;

import java.util.List;

import com.platform.common.annotation.DataScope;
import com.platform.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.platform.system.mapper.ProCollectMapper;
import com.platform.system.domain.ProCollect;
import com.platform.system.service.IProCollectService;

/**
 * 收藏Service业务层处理
 *
 * @author platform
 * @date 2025-02-23
 */
@Service
public class ProCollectServiceImpl implements IProCollectService {
    @Autowired
    private ProCollectMapper proCollectMapper;

    /**
     * 查询收藏
     *
     * @param id 收藏主键
     * @return 收藏
     */
    @Override
    public ProCollect selectProCollectById(Long id) {
        return proCollectMapper.selectProCollectById(id);
    }

    /**
     * 查询是否收藏
     *
     * @return 收藏
     */
    @Override
    public ProCollect selectProCollectExist(Long productId, Long userId) {
        return proCollectMapper.selectProCollectExist(productId, userId);
    }

    /**
     * 查询收藏列表
     *
     * @param proCollect 收藏
     * @return 收藏
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<ProCollect> selectProCollectList(ProCollect proCollect) {
        return proCollectMapper.selectProCollectList(proCollect);
    }

    /**
     * 查询收藏列表
     *
     * @param proCollect 收藏
     * @return 收藏
     */
    @Override
    public List<ProCollect> selectProCollectListAll(ProCollect proCollect) {
        return proCollectMapper.selectProCollectListAll(proCollect);
    }

    /**
     * 新增收藏
     *
     * @param proCollect 收藏
     * @return 结果
     */
    @Override
    public int insertProCollect(ProCollect proCollect) {
        proCollect.setCreateTime(DateUtils.getNowDate());
        return proCollectMapper.insertProCollect(proCollect);
    }

    /**
     * 修改收藏
     *
     * @param proCollect 收藏
     * @return 结果
     */
    @Override
    public int updateProCollect(ProCollect proCollect) {
        proCollect.setUpdateTime(DateUtils.getNowDate());
        return proCollectMapper.updateProCollect(proCollect);
    }

    /**
     * 批量删除收藏
     *
     * @param ids 需要删除的收藏主键
     * @return 结果
     */
    @Override
    public int deleteProCollectByIds(Long[] ids) {
        return proCollectMapper.deleteProCollectByIds(ids);
    }

    /**
     * 删除收藏信息
     *
     * @param id 收藏主键
     * @return 结果
     */
    @Override
    public int deleteProCollectById(Long id) {
        return proCollectMapper.deleteProCollectById(id);
    }
}
